var http = require('http');
var url = require('url');

var students = [{ name: 'John', email: 'aa', age: 18 },
{ name: 'lisi', email: 'aa', age: 20 },
{ name: 'wuang', email: 'aa', age: 19 },
{ name: 'maliu', email: 'aa', age: 17 },]
http.createServer(function (request, response) {
    var pathobj = url.parse(request.url, true);
    switch (pathobj.pathname) {nod
        case '/students':
    response.writeHead(200, { 'Content-Type': 'text/json' });
    response.end(JSON.stringify(students));
    break;
        default:
    response.writeHead(200, { 'Content-Type': 'text/html' });
    response.end("<h1>请访问/students</h1>".toString('utf-8'));
    break;
}

}).listen(5000);

console.log('Server running at http://127.0.0.1:5000/students');